import { CHANGE_NUM, CHANGE_SIZE, GET_ALL_ORDER, MODIFY_ORDER_STATUS } from '@/store/order/const'
import { orders, order, State } from '@/store/order/intereface'

export default {
  [GET_ALL_ORDER] (state:State, data:{count:number, data: orders }) {
    console.log(data)
    state.orders = data.data
    state.count = data.count
  },

  [MODIFY_ORDER_STATUS] (state:State, data:order) {
    state.currentOrder = data
    state.orders = state.orders.map(item => {
      if (item.order_id === data.order_id) item = data
      return item
    })
  },
  [CHANGE_SIZE] (state:State, size:number) {
    state.pagesize = size
  },
  [CHANGE_NUM] (state:State, num:number) {
    state.pagenum = num
  }
}
